// hyb_menzhen/detail/pages/doctor_detail/doctor_detail.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    type_index: 0,
    type:["医生简介","患者口碑"],
    did:"",
    types:"",
    id:"",
    page:0,
    pingjia:[]
  },
  bindtype(e){
    this.setData({
      type_index:e.currentTarget.dataset.index
    })
  },
  bindall(e){
    this.setData({
      type_index:1
    })
  },
  // 展开
  bindsc(e){
    this.setData({
      sc_show:!this.data.sc_show
    })
  },
  bindjj(e){
    this.setData({
      jj_show:!this.data.jj_show
    })
  },
  // 医馆看诊
  bindyiguan(e){
    // did=1&server=yuyuejiuzhen&money=11.00&hid=30&keshi_two=100&tid=32&leixing=lvtong&name=预约就诊&zid=
    var that = this;
    var server = that.data.server;
    if(server == 'yuyuejiuzhen' || that.data.types == 'uptime')
    {
      wx.navigateTo({
        url: '/hyb_yl/userCommunicate/pages/jiuzhen_date/jiuzhen_date?did='+that.data.did+'&server='+that.data.server+'&money='+that.data.money+'&hid='+that.data.hid+'&keshi_two='+that.data.keshi_two+'&tid='+that.data.tid+'&leixing=lvtong&name='+that.data.name+'&zid='+that.data.zid+'&week='+e.currentTarget.dataset.week+'&time='+e.currentTarget.dataset.time+'&id='+that.data.id+'&types='+that.data.types,
      })
    }else{
      wx.navigateTo({
        url: '/hyb_yl/zhuanjiasubpages/pages/zhuanjiatiwens/zhuanjiatiwens?did='+that.data.did+'&server='+that.data.server+'&money='+that.data.money+'&hid='+that.data.hid+'&keshi_two='+that.data.keshi_two+'&tid='+that.data.tid+'&leixing=lvtong&name='+that.data.name+'&zid='+that.data.zid+'&week='+e.currentTarget.dataset.week+'&time='+e.currentTarget.dataset.time,
      })
    }
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var did = options.did;
    var server = options.server;
    var money = options.money
    var hid = options.hid;
    var keshi_two = options.keshi_two;
    var tid = options.tid
    var leixing = options.leixing;
    var name = options.name;
    var zid = options.zid;
    that.setData({
      did:did,
      server:server,
      money:money,
      hid:hid,
      keshi_two:keshi_two,
      tid:tid,
      leixing:leixing,
      name:name,
      zid:zid,
      bgc:wx.getStorageSync('color')
    })
    var types = options.types;
    var id = options.id;
    if(types != '' && types != undefined)
    {
      that.setData({
        types:types,
        id:id
      })
    }
    // 获取客服详情
    that.getGreen();
    that.getPingjia();
  },
  getGreen:function(res){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/green.green_detail",
      data:{
        did:that.data.did
      },
      success:function(res){
        that.setData({
          info:res.data
        })
      }
    })
  },
  getPingjia:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/green.getPingjia",
      data:{
        page:that.data.page,
        did:that.data.did,
      },
      success:function(res)
      {
        var page = that.data.page + 1;
        that.setData({
          page:page,
          pingjia:that.data.pingjia.concat(res.data)
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    if(this.data.type_index == 1)
    {
      that.getPingjia();
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})